package ptaTest5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Test553 {

public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	Map<String, Integer> num = new TreeMap<String, Integer>();
	while (in.hasNext()) {
		String str = in.next();
		if (str.equals("!!!!!"))
			break;
		else if (!num.containsKey(str))
			num.put(str, 1);
		else {
			  int n = (int) num.get(str);
			  num.put(str, n + 1);
			 }
		}		
	System.out.println(num.size());
	List<Map.Entry<String, Integer>> arrayList = new ArrayList<Map.Entry<String, Integer>>(num.entrySet());
	Collections.sort(arrayList, new Comparator<Map.Entry<String, Integer>>() {
	public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
		return ((Integer) o2.getValue()) - ((Integer) o1.getValue());
	    }
	});
		
	int n=10;
	for (Map.Entry<String, Integer> entry : arrayList) {
		if(n--==0)
			break;
		String key = entry.getKey();
		Integer value = entry.getValue();
		System.out.println(key + "=" + value);
	}

	in.close();
	}
}





